<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateAdminLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('admin_logs')) {
            Schema::create('admin_logs', function (Blueprint $table) {
                $table->id();
                $table->integer('uid')->nullable()->comment('操作的用户 ID');
                // $table->string('project_key', 32)->comment('项目码');
                // $table->string('unique_label')->comment('日志操作项目唯一性标签')->index();
                $table->string('path')->default('/')->comment('日志请求路径');
                $table->string('uses')->nullable()->comment('路由类');
                $table->enum('method', ['OPTION', 'GET', 'POST', 'DELETE', 'PUT', 'PATCH', 'HEAD', 'COPY'])->default('POST')->comment('Method');
                $table->mediumText('params')->comment('请求参数');
                $table->mediumText('result')->comment('结果数据');
                $table->string('message')->nullable()->comment('内容');
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `admin_logs` comment '管理员日志表'");
        }
        
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_logs');
    }
}
